import { createApp } from "vue";
import App from "./App.vue";
import Antd from 'ant-design-vue';
import 'vxe-table/lib/style.css'
import 'ant-design-vue/dist/antd.less'
import '@/assets/theme/theme.scss';
import { createPinia } from 'pinia'
import router from '@/router'

import "@/assets/css/resetAntd.less"
import "@/assets/css/resetVxeTable.less"
import "@/assets/font/iconfont.css"
import "@/assets/css/reset.scss"
import ColorPicker from 'colorpicker-v3'
import 'colorpicker-v3/style.css'
import i18n from '@/locales'
import { setupRouter } from './router';
import piniaPluginPersist from 'pinia-plugin-persist'
import 'xe-utils'
import VXETable from 'vxe-table'
import preReClick from './directives/preReclick';
import { useLocale } from '@/locales/useLocale';
// 正式环境清除所有console.log
if (process.env.NODE_ENV === 'production') {
  if (window) {
    window.console.log = function () {};
  }
}
// 全局注册组件（也可以使用局部注册）
const { getAntdLocale, changeLocale } = useLocale();
if (sessionStorage.LOCALE_KEY) {
  changeLocale(JSON.parse(sessionStorage.LOCALE_KEY).value);
} else {
  changeLocale('zh_CN');
}
console.log(i18n, 'i18n')
const app = createApp(App);
app.use(createPinia().use(piniaPluginPersist))
app.use(Antd);
app.use(router)
app.use(i18n)
app.use(VXETable);
app.use(preReClick)
app.use(ColorPicker)
async function setupApp() {
  // 挂载vuex状态管理
  // setupStore(app);
  // Multilingual configuration
  // Asynchronous case: language files may be obtained from the server side
  // await setupI18n(app);
  // 挂载路由
  await setupRouter(app);
  app.mount('#app');
}
setupApp();
